import { get, post } from "@/utils/request"

// 聊天室列表
export const chatroomListServer = (name:string) => {
    return post('/chatroom/list' , {
        name
    })
}

// 创建一对一聊天室
export const createOneChatServer = (friendId:number) => {
    return post('/chatroom/create-one' , {
        friendId
    })
}

// 创建群聊
export const createGroupServer = (name:string) => {
    return post('/chatroom/create-group' , {
        name
    })
}

// 聊天室详细信息
export const chatInfoServer = (id:number) => {
    return get(`/chatroom/info?chatroomId=${id}`)
}

// 加入群聊
export const joinChatServer = (chatroomId:number , userlist: number[]) => {
    return post('/chatroom/join' , {
        chatroomId,
        userlist
    })
}

// 查询可加入群聊的好友
export const canJoinServer = (chatroomId:number) => (
    post('/chatroom/can-join' , {
        chatroomId
    })
)

// 退出聊天室
export const quitchatServer = (chatroomId:number) => {
    return post('/chatroom/quit' , {
        chatroomId
    })
}

// 获取聊天记录
export const chatHistoryServer = (chatroomId:number) => {
    return post('/chat-history/list' , {
        chatroomId
    })
}

// 查找聊天室
export const foundChatServcer = (friendId:number) => (
    post('/chatroom/getOneToOne' , {friendId})
)